﻿using MediatR;
using Practice.Common.Domains;
using Practice.Common.Dto;
using Practice.Common.Infrastructure.Interfaces;

namespace Practice.API.Application.Commands.Permissionw
{
    public class PermissionFillHandler : IRequestHandler<PermissionFillCommand, List<Permission>>
    {
        public readonly IBaseRepository<Permission> PermissionRepository;

        public PermissionFillHandler(IBaseRepository<Permission> permissionRepository)
        {
            PermissionRepository = permissionRepository;
        }

        public async Task<List<Permission>> Handle(PermissionFillCommand request, CancellationToken cancellationToken)
        {
            var list = PermissionRepository.GetAll().Where(x => x.PermissionId == request.PermissionId).ToList() ;
            return list;
        }
    }
}
